package 力扣._00周赛._428周赛.问题1;

class Solution {
    public int buttonWithLongestTime(int[][] events) {
        int max = events[0][1];
        int last = 0;
        int max_index = events[0][0];
        for (int[] event : events) {
            int now = event[1] - last;
            if (now > max) {
                max = now;
                max_index = event[0];
            }else if(now == max){
                max_index = Math.min(max_index, event[0]);
            }

            last = event[1];
        }
        return max_index;
    }
}